package com.situ.mall.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

/**
 * @ClassName IndexController
 * @Description 负责一些页面的跳转
 * @Author 周轩霆
 * @Date 2022/8/16 16:06
 **/
@Controller
public class IndexController {
    //日志相关
    private Logger logger = LoggerFactory.getLogger(IndexController.class);

    @RequestMapping("/")
    public String index() {
        return "index";
    }


    @RequestMapping("/login")
    public String toLogin() {
        return "login";
    }

    @RequestMapping("/logout")
    public String toLoginOut(HttpSession session) {
        //注销后 session失效 跳转页面
        session.invalidate();
        return "login";
    }

    @RequestMapping("toEcharts")
    public String toEcharts() {
        return "echarts";
    }


    @RequestMapping("/log")
    @ResponseBody

    public String log() {
        logger.debug("debug:hello");
        logger.info("info:info");
        logger.warn("warn:info");
        logger.error("debug:error");
        return "log!!!!";
    }

    @RequestMapping("/getProductListPage")
    public String getProductListPage() {
        return "product_list";
    }

    @RequestMapping("/getProductAddPage")
    public String getProductAddPage() {
        return "product_add";
    }


}
